/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package za.ac.cput.nomaphelo.designpatterns.creational.config;

import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.annotation.Bean;
import za.ac.cput.nomaphelo.designpatterns.creational.abstractfactory.AbstractFactory;
import za.ac.cput.nomaphelo.designpatterns.creational.builder.ItalianMealBuilder;
import za.ac.cput.nomaphelo.designpatterns.creational.builder.JapaneseMealBuilder;
import za.ac.cput.nomaphelo.designpatterns.creational.builder.MealBuilder;
import za.ac.cput.nomaphelo.designpatterns.creational.builder.MealDirector;
import za.ac.cput.nomaphelo.designpatterns.creational.factory.AnimalFactory;
import za.ac.cput.nomaphelo.designpatterns.creational.prototype.Dog;
import za.ac.cput.nomaphelo.designpatterns.creational.prototype.Person;

/**
 *
 * @author spheshie
 */
@Configurable
public class CreationalConfig {

    @Bean(name = "animal")
    public AnimalFactory animalFactory() {
        return new AnimalFactory();
    }

    @Bean(name = "abstract")
    public AbstractFactory abstractFactory() {
        return new AbstractFactory();
    }

    @Bean(name = "italian")
    public MealDirector italianMeal() {
        MealBuilder italianMealBuilder = new ItalianMealBuilder();
        return new MealDirector(italianMealBuilder);
    }
    
    @Bean(name = "japanese")
    public MealDirector japaneseMeal() {
        MealBuilder japaneseMealBuilder = new JapaneseMealBuilder();
        return new MealDirector(japaneseMealBuilder);
    }
    
    @Bean(name = "person1")
    public Person person1() {
        return new Person("Fred");
    }
    
    @Bean(name = "person2")
    public Person person2() {
        Person person2 = (Person) person1().doClone();
        return person2;
    }
    
    @Bean(name = "dog1")
    public Dog dog1() {
        return new Dog("woof");
    }
    
   @Bean(name = "dog2")
    public Dog dog2() {
        Dog dog2 = (Dog) dog1().doClone();
        return dog2;
    }
}
